/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author fernando
 */
public class ConexaoPostgres implements Conexao, Serializable {
    private String driver = "org.postgresql.Driver";
    /*private String URL = "jdbc:postgresql://localhost:5432/GestaoSocial";
    private String usuario = "postgres";
    private String senha = "postgres";*/
    private String URL = "jdbc:postgresql://pgsql_prod01.intranet.ufba.br:5432/observatoriofgsdb";
    private String usuario = "observausr";
    private String senha = "observa2211";
    private Connection con;
    
    
    
    @Override
    public Connection getConnection() {
        try {
            Class.forName(driver);
            con = (Connection)DriverManager.getConnection(URL, usuario, senha);
        }    
        catch (SQLException ex) {
            Logger.getLogger(ConexaoPostgres.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (ClassNotFoundException ex) {
            Logger.getLogger(ConexaoPostgres.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return con;
    }
    
    @Override
    public void closeConnection(){
        try {
            con.close();
        } catch (SQLException ex) {
            Logger.getLogger(ConexaoPostgres.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
}
